1. Field of the Invention
The present invention relates to computer software, and deals more particularly with a method and apparatus for using a database to store program logs. The amount of data stored can be reduced using data normalization. Data retrieval and display, including statistics and report generation, is simplified by using the existing facilities of the database manager.
2. Description of the Related Art
Software products are customarily written to generate information on the tasks which they perform. The more complex the program, the more important it is to generate information about what is occurring in the program, in case something should go wrong. In the early days of computer use, programs logged information by sending text strings to a dedicated printer, or console, in real time. A human operator could then determine what was occurring in the program by inspecting the log entries as they were written, or by reading the entries that had been written out over a period of time. The log-creation process has evolved over time, to where log information is now written into disk files instead of directly to a printer. These disk files are commonly referred to in a general sense as "program logs", or simply "logs". Some products may create more than one such file, to separate classes of information. An example of this separation could be storing data of interest to the end user in one file (for example, an "activity log") while storing information of interest to a developer in a different file (a "trace log", for example). In either case, the log is a flat file, ordered sequentially according to the time each entry is made. A "flat file" is a file containing simple records that have no complex structure, and no explicit relationships between entries, other than their sequential order. The entries in the flat file consist of fully-formed, human-readable messages. These flat files have no inherent means for sorting, filtering, or analyzing the data they contain. A simple text editor may be used to display the contents of the log, but this does not allow the data to be processed in any way (such as sorting or filtering) to facilitate meaningful interpretation. Alternatively, a custom-written software program may be written to display the log. Custom-written programs are required in order to manipulate the entries in the log--for example, to select only certain entries for viewing, to change the order of the entries, or to revise the contents of entries.
Writing messages that are fully-formed leads to redundant data being stored in the files. When an application logs many messages, the log files can grow to be quite large. When the message text is long, and the same message is logged many times, this is an inefficient use of system resources.
Accordingly, a need exists for a technique by which program-generated logs can be created in a more usable, efficient manner. The present invention provides a technique for storing the messages of program logs in databases. The messages are stored in multiple database files, in order to allow normalization of the message content. Further, the messages are stored in computer-readable form, instead of human-readable form. This technique enables optimization of the storage used for storing the log entries, and eliminates the storage of redundant message text. In addition, this technique allows quick, efficient analysis of log entries without writing custom software, because the report-generating facilities of the database manager--which are provided as part of the database software--can be used. Because the messages are stored in computer readable form, they can be translated into other languages easily and efficiently.